package ldh.im.rpc.connection.handle;

import ldh.im.rpc.config.RpcConfig;
import ldh.im.rpc.dto.RpcData;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class DefaultRpcContext implements RpcContext {

    private Map<String, Object> dataMap = new HashMap<>();
    private RpcData rpcData;
    private RpcSession session;
    private RpcConfig rpcConfig;

    public DefaultRpcContext(RpcConfig rpcConfig, RpcSession session, RpcData rpcData) {
        this.rpcConfig = rpcConfig;
        this.session = session;
        this.rpcData = rpcData;
    }

    @Override
    public void put(String key, Object value) {
        dataMap.put(key, value);
    }

    @Override
    public Object get(String key) {
        return dataMap.get(key);
    }

    @Override
    public Collection<Object> values() {
        return dataMap.values();
    }

    @Override
    public RpcSession getSession() {
        return session;
    }

    @Override
    public RpcConfig getRpcConfig() {
        return rpcConfig;
    }

    public void setSession(RpcSession session) {
        this.session = session;
    }

    @Override
    public RpcData getRpcData() {
        return rpcData;
    }

    public void setRpcData(RpcData rpcData) {
        this.rpcData = rpcData;
    }
}
